﻿/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2012-2018. All rights reserved.
 * Description:
 * Author: 辛爱国 x30005137
 * Create: 2020-07-28
 * Notes: 无
 */
#include "reconfirmation.h"
#include <QGraphicsDropShadowEffect>
#include <QPixmap>
#include <qapplication.h>
#include <QDesktopWidget>
#include <qscreen.h>

ReConfirmation::ReConfirmation(QWidget *parent, TIPTYPE_E is) : HWDialog(parent)
{
    setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
    shadow_effect->setOffset(0, 0); // 0, 0设置的参数
    QColor color(0, 0, 0, 20); // 0, 0, 0, 20颜色值
    shadow_effect->setColor(color);
    shadow_effect->setBlurRadius(30); // 设置阴影半径30
    this->ReConwidgetWindow->setGraphicsEffect(shadow_effect);
    this->leavecheckBox->setText(QObject::tr("Leave and stop meetting"));
    if (is == TIPTYPE_E::IDEASHARE_NOMAL) {
        this->SetCheckboxVisible(false);
        QRect rec = this->ReConwidgetWindow->geometry();
        this->ReConwidgetWindow->setGeometry(rec.x(), rec.y(), this->ReConwidgetWindow->width(), this->ReConwidgetWindow->height() - 32); // 高减小32
        this->setGeometry(rec.x(), rec.y(), this->width(), this->height() - 30); // 移动的按钮30
        rec = this->pushButtonReOK->geometry();
        this->pushButtonReOK->setGeometry(rec.x(), rec.y() - 30, this->pushButtonReOK->width(), this->pushButtonReOK->height()); // y减小30
        rec = this->pushButtonReCancel->geometry();
        this->pushButtonReCancel->setGeometry(rec.x(), rec.y() - 30, this->pushButtonReCancel->width(), this->pushButtonReCancel->height()); // y减小30
    } else if (is == TIPTYPE_E::IDERSHARE_MEET) {
        this->SetCheckboxVisible(true);
    } else {}
    saveChildrenInfo();
}

void ReConfirmation::SetTextAndLoge(const QString& text, const QString& url)
{
    this->labelTitle->setText(text);
    this->labelConLoge->setScaledContents(true);
    this->labelConLoge->setPixmap(QPixmap(url));

    this->labelTitle->setWordWrap(true);
}

void ReConfirmation::SetTex(QString &text)
{
    this->labelConLoge->setScaledContents(true);
    this->labelTitle->setWordWrap(true);
    this->labelTitle->setText(text);
    QPoint curPoint = this->labelTitle->pos();
    this->labelTitle->setGeometry(curPoint.x(), curPoint.y(), 250, 70); // 250宽70高
    this->labelTitle->move(QPoint(68, -30) + curPoint); // 距离边68，y上移30
//    if (ideasharesdk::config::language.value() == ideasharesdk::CHINESE) {
//        this->labelTitle->move(QPoint(68, -30) + curPoint); // 距离边68，y上移30
//    } else {
//        this->labelTitle->move(QPoint(68, -50) + curPoint); // 距离边68，y上移50
//    }

    saveChildrenInfo();
}
ReConfirmation::~ReConfirmation() {}

void ReConfirmation::SetCheckboxVisible(bool status)
{
    this->leavecheckBox->setVisible(status);
}

bool ReConfirmation::GetCheckboxVisibleStatus()
{
    return this->leavecheckBox->isChecked();
}
void ReConfirmation::on_pushButtonExit_clicked()
{
    QDialog::reject();
}

void ReConfirmation::on_pushButtonReOK_clicked()
{
    QDialog::accept();
}
void ReConfirmation::on_pushButtonReCancel_clicked()
{
    QDialog::reject();
}
